import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { defHttp } from '/@/utils/http/axios';
import { UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload';
import { render, formattingMin, formattingDay, formatTimestamp } from '/@/utils/common/renderUtils';

//表单数据--更换行程--需要根据出发时间、目的地景点、出发城市--选出行程，大团则需选择上车地点，小团选择定位或者用户自己在前端选
export const formSchemaUpdateJounery : FormSchema[] = [

	{
		label: '',
		field: 'orderId',
		component: 'Input',
		show: false
	},
	{
		label: '游玩天数',
		field: 'travelDays',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入旅游天数!' },
			];
		},
		// dynamicDisabled: true
	},
	{
		label: '出发日期',
		field: 'startdateStr',
		component: 'DatePicker',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择出发日期!' },
			];
		},
	},
	{
		label: '出发城市',
		field: 'cityId',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'sys_category,name,city_id,pid="1760922454642933761"'
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择出发城市。!' },
			];
		},
		/* dynamicDisabled: ({ values }) => {
			return values.isUpdate == true
		}, */
	},
	{
		label: '目的地景点',
		field: 'destination',
		component: 'JSearchSelect',
		componentProps: {
			dict: 'BS_Scenic,title,id',
			pageSize: 10,
			async: true
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择目的地景点。!' },
			];
		},
		/* dynamicDisabled: ({ values }) => {
			return values.isUpdate == true
		}, */
	},
	{
		label: '选择替换的行程',
		field: 'travelId',
		component: 'ApiSelect',
		required: true,
		componentProps: ({ formActionType, formModel }) => {

			if (formModel.cityId && formModel.travelDays && formModel.destination && formModel.startdateStr) {
				return {
					//multiple: 多选；不填写为单选
					mode: '',
					//请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
					api: () => defHttp.get({ url: '/journey/bsTravelgroupMaintuortravellinerecord/getJounerysByCondition?cityId=' + formModel.cityId + '&travelDays=' + formModel.travelDays + '&destination=' + formModel.destination + '&startdateStr=' + formModel.startdateStr }),
					//数值转成String
					numberToString: true,
					//标题字段
					labelField: 'title',
					//值字段
					valueField: 'jouneryId',
					//请求参数
					params: {
					},
					//返回结果字段
					resultField: 'records'
				}
			}
		},
		/* 	colProps:{
				span:12
			}, */
		/* 	dynamicDisabled: ({ values }) => {
				return values.isUpdate == true
			}, */
	},
];

export const formSchemaGiveTicket : FormSchema[] = [

	{
		label: '',
		field: 'orderId',
		component: 'Input',
		show: false
	},

	{
		label: '选择优惠券',
		field: 'ticketId',
		component: 'JSearchSelect',
		componentProps: {
			dict: 'couple_discount_coupon,title,id',
			async: true,
			pageSize: 10,
		}

	},
	{
		label: '过期时间',
		field: 'expirationTime',
		component: 'DatePicker',
		componentProps: {
			showTime: true,
			valueFormat: 'YYYY-MM-DD HH:mm:ss'
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择优惠券过期时间!' },
			];
		},
	},

]

export const formSchemaRefundPrice : FormSchema[] = [

	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},

	{
		label: '退款类型',
		field: 'refundType',
		component: 'Input',
		show: false
	},
	{
		label: '退款金额',
		field: 'refundPrice',
		component: 'Input',
	},
]

export const formSchemaUpdateHomePageTypeBigTeam : FormSchema[] = [

	{
		label: '',
		field: 'groupId',
		component: 'Input',
		show: false
	},

	{
		label: '选择类别',
		field: 'typeHomePage',
		component: "Input",
		slot: 'selectHomePageType',
		required: true
	},
	{
		label: '选择类别',
		field: 'typeIds',
		component: "Input",
		show: false
	},

]


export const formSchemaUpdateHomePageTypeLittleTeam : FormSchema[] = [

	{
		label: '',
		field: 'mainId',
		component: 'Input',
		show: false
	},

	{
		label: '选择类别',
		field: 'typeHomePage',
		component: "Input",
		slot: 'selectHomePageType',
		required: true
	},
	{
		label: '选择类别',
		field: 'typeIds',
		component: "Input",
		show: false
	},

]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}